package me.ywd.poker.entity;

import me.ywd.poker.Common;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by AOC3 on 2017/2/23.
 */
public class Poker {
    private String number;
    private String color;

    public Poker() {

    }

    public Poker(String name) {
        this.setNumber(name.substring(0, 1));
        this.setColor(name.substring(1));
    }

    @Override
    public boolean equals(Object o) {
        Poker poker = (Poker) o;
        if (this.getNumber().equals(poker.getNumber()) && this.getColor().equals(poker.getColor())) return true;
        else return false;
    }

    public int position() {
        List<String> numbers = new ArrayList<String>();
        for (String number : Common.NUMBERS) {
            numbers.add(number);
        }
        return 14 - numbers.indexOf(this.number);
    }

    @Override
    public String toString() {
        return number + color;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}
